package com.stusy.blog.everythingcanblog.service.impl;

import com.stusy.blog.everythingbloginterface.bean.UserInfo;
import com.stusy.blog.everythingbloginterface.service.LoginService;
import com.stusy.blog.everythingbloginterface.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author Xinpei Li
 * @create 2022-02-17 20:48
 */

@DubboService
@Slf4j
public class LoginServiceImpl implements LoginService {

    @DubboReference
    private UserInfoService userInfoService;

    @Override
    public boolean login(String userName, String passWord) {
        UserInfo userInfo = userInfoService.getUserInfo(userName);
        log.info("[LoginService] login userName={}",userName);
        if(Objects.nonNull(userInfo) && Objects.equals(passWord,userInfo.getPassWord())){
            return true;
        }
        return false;
    }
}
